n=input()
f=1
while n!='' and f==1:
    f=0
    while '()' in n:
        n=n.replace('()','',1)
        f=1
    while '[]' in n:
        n=n.replace('[]','',1)
        f=1
    while '{}' in n:
        n=n.replace('{}','',1)
        f=1
    while '<>' in n:
        n=n.replace('<>','',1)
        f=1
if n=='':
    print('True')
else:
    print('False')